<?php

declare(strict_types=1);
namespace App\Service\AppService;
use App\Service\BaseService;
use App\Service\InterfaceService\IdSeviceInterface;

class IdService extends BaseService implements IdSeviceInterface
{
    /**
     * 获取订单ID
     */
    public function getOmsID()
    {
        return file_get_contents(self::getServerUri().'/Rpc/SnowFlake/getOmsID');
    }
    
    /**
     * 获取OTHER ID
     */
    public function getOtherID()
    {
        return file_get_contents(self::getServerUri().'/Rpc/SnowFlake/getOtherID');
    }
    
    /**
     * 获取Log ID
     */
    public function getLogID()
    {
        return file_get_contents(self::getServerUri().'/Rpc/SnowFlake/getLogID');
    }
    
    /**
     * 获取Goods ID
     */
    public function getGoodsID()
    {
        return file_get_contents(self::getServerUri().'/Rpc/SnowFlake/getGoodsID');
    }
    
    /**
     * 获取ID服务中心地址
     * @return string|void|boolean|\Closure
     */
    private function getServerUri()
    {
        $env_snow_flake_url = env('SNOW_FLAKE_URL');
        $env_server_ip = env('SERVER_IP');
        return $env_snow_flake_url ? $env_snow_flake_url : ($env_server_ip ? "http://{$env_server_ip}:9331" : 'http://127.0.0.1:9331');
    }
}